function [ auc ] = AUC( Y_est, Y)
%AUC Summary of this function goes here
%   Detailed explanation goes here
miny = min(min(Y_est));
maxy = max(max(Y_est));
[N,L] =size(Y);
n = N*L;
for k=0:99
    z= find(Y_est > miny+k/100*(maxy-miny));
    zz= setdiff(1:n, z);
    z0 = find(Y==-1);
    z1 = find(Y==1);
    tp(k+1) = length(intersect(z,z1));
    tn(k+1) = length(intersect(zz,z0));
    fp(k+1) = length(intersect(z,z0));
    fn(k+1) =length(intersect(zz,z1));
end
tp=tp./(tp+fn);
fp=fp./(tn+fp);
% plot(fp,tp);hold on
auc=sum(abs(fp(2:length(fp))-fp(1:length(fp)-1)).*tp(2:length(fp)));
end

